import React, {Component} from 'react';
// 一般组件不带有路由组件所带的histroy,match,location对象.要想操作router，需引入withRouter
import {withRouter} from 'react-router-dom'

class Header extends Component {
  render() {
    return (
      <div className="row">
        <div className="col-xs-offset-2 col-xs-8">
          <div className="page-header"><h2>React Router Demo</h2></div>
        </div>
        <button onClick={() => {
          this.props.history.goBack()
        }}>back
        </button>
        <button onClick={() => {
          this.props.history.goForward()
        }}>forward
        </button>
      </div>
    );
  }
}

// withRouter可以加工一般组件
export default withRouter(Header);
